#ifndef __USB_COMM_H__
#define __USB_COMM_H__
#include "hc32_ll.h"


#define HOST_REQ_DEVPARA    (0x81)
#define HOST_REQ_REGPARA    (0x82)
#define HOST_REQ_MEADATA    (0x83)
#define HOST_REQ_UPDATE     (0x85)
#define HOST_TRA_FIRMWARE   (0x86)
#define HOST_SET_REGPARA    (0x87)
#define HOST_SET_DEVPARA    (0x88)
#define HOST_SET_DEVTIME    (0x89)

#define DEV_ACQ_DEVPARA     (0x01)
#define DEV_ACQ_REGPARA     (0x02)
#define DEV_ACQ_MEADATA     (0x03)
#define DEV_UPL_IRMATRIX    (0x04)
#define DEV_ACQ_FIRMWARE    (0x06)
#define DEV_ACQ_SETREG      (0x07)
#define DEV_ACQ_SETDEV      (0x08)
#define DEV_ACQ_SETTIME     (0x09)


#define DEV_MSG_DLC_LEN     (3U)
#define DEV_MSG_TYPE_LEN    (1U)
#define DEV_MSG_HDR_LEN     (DEV_MSG_DLC_LEN + DEV_MSG_TYPE_LEN)

//0x81
#define DEV_PARA_SN_LEN     (10U)
#define DEV_PARA_VER_LEN    (3U)
#define DEV_PARA_ADDR_LEN   (1U)
#define DEV_PARA_UV_LEN     (2U)
#define DEV_PARA_485_LEN    (2U)
#define DEV_PARA_433_LEN    (2U)
#define DEV_MSG_0x81_LEN    (DEV_PARA_SN_LEN + DEV_PARA_VER_LEN \
                            +DEV_PARA_ADDR_LEN + DEV_PARA_UV_LEN \
                            +DEV_PARA_485_LEN + DEV_PARA_433_LEN )

#define DEV_MSG_0x88_LEN    (DEV_PARA_ADDR_LEN + DEV_PARA_UV_LEN \
                            +DEV_PARA_485_LEN + DEV_PARA_433_LEN )

//0x82

#define DEVICE_SN           ("123456789A")
#define DEV_CMD_MAX_SIZE    (1024U)
#define HOST_CMD_MAX_SIZE   (1024U)
/*******************************************************************************
  Global function prototypes (definition in C source)
 ******************************************************************************/
extern void vcp_ctrlpare(uint32_t Cmd, uint8_t *Buf, uint32_t Len);
extern void vcp_rxdata(uint8_t *Buf, uint32_t Len);


int32_t usb_receive_firmware(void);
int32_t usb_check_firmware(void);
int32_t usb_write_firmware(void);
int32_t usb_sysneedreset(void);


#endif